﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TBM.Filters
{
    public class ExceptionFillters : FilterAttribute, IExceptionFilter
    {
        //发生异常时会执行这段代码
        public void OnException(ExceptionContext filterContext)
        {
            // 异常处理
            Type exceptionType = filterContext.Exception.GetType();
            filterContext.ExceptionHandled = true;

            if (typeof(InvalidOperationException) == exceptionType)
            {
                filterContext.Result = new RedirectResult("~/JsRsp/Error?errorCode=3");
            }
        }
    }
}